package com.itboye.zhujia;

import java.util.ArrayList;
import java.util.List;

import android.R.integer;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.alipay.android.phone.mrpc.core.r;
import com.itboye.zhujia.adapter.ZhuJiaWuYeAdapter;
import com.itboye.zhujia.base.BaseFragment;
import com.itboye.zhujia.custom.XGridView;
import com.itboye.zhujia.myzhujia.ActivityCityLife;
import com.itboye.zhujia.myzhujia.ActivityHoseKeepingService;
import com.itboye.zhujia.myzhujia.ActivityLivePayment;
import com.itboye.zhujia.myzhujia.ActivityRepair;
import com.itboye.zhujia.myzhujia.ActivitySmartLock;
import com.itboye.zhujia.myzhujia.ActivityTravel;
import com.itboye.zhujia.util.ByAlert;
/**
 * 服务
 *
 */
public class ServiceFragment extends BaseFragment {

	XGridView gridView;
	// gridView2;
	List<String> list = new ArrayList<>();
	List<Integer> list2 = new ArrayList<>();
	ImageView close_icon;
	String[] strings = { "住家维修", "生活缴费", "智能门锁", "签约旅行", "城市生活", "家政服务" };
	int[] imgs = { R.drawable.app_loading1, R.drawable.app_loading0,
			R.drawable.app_loading1, R.drawable.app_loading0,
			R.drawable.app_loading1, R.drawable.app_loading0 };
	TextView add_shap_title_tv;

	@Override
	public int initView() {
		return 0;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.service_layout, null);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		for (int i = 0; i < strings.length; i++) {
			list.add(strings[i] + "");
			list2.add(imgs[i]);
		}
		gridView.setAdapter(new ZhuJiaWuYeAdapter(getActivity(), list2, list,
				R.layout.item_service));
		// gridView2.setAdapter(new ZhuJiaWuYeAdapter(getActivity(), list,
		// R.layout.item_service));
	}

	@Override
	public void onMyActivityCreated() {
		add_shap_title_tv.setText("住家生活");
		gridView.setOnItemClickListener(new OnItemClickListener() {
			Intent intent;

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				if (arg2 == 0) {
					intent = new Intent(getActivity(), ActivityRepair.class);
				} else if (arg2 == 1) {
					intent = new Intent(getActivity(),
							ActivityLivePayment.class);
				} else if (arg2 == 2) {
					intent = new Intent(getActivity(), ActivitySmartLock.class);
				} else if (arg2 == 3) {
					intent = new Intent(getActivity(), ActivityTravel.class);
				} else if (arg2 == 4) {
					intent = new Intent(getActivity(), ActivityCityLife.class);
				} else if (arg2 == 5) {
					intent = new Intent(getActivity(),
							ActivityHoseKeepingService.class);
				}
				startActivity(intent);
			}
		});
	}

}
